// base
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
// less
import './index.less'
import { navigateTo } from '../../../crossplatform/apiservice/navigate'
import pagejumplist from '../../../configuration/pagejumplist.json'
import JobListItem from '../job-list-item'

class JobsList extends Component {
  state = {
    list: [{}, {}]
  }

  componentWillMount () {
    // onLoad
  }

  componentDidMount () {
    // onready
  }

  componentDidShow () {
    // onshow
  }

  componentDidHide () {
    // onhide
  }

  componentWillUnmount () {
    // onUnload
  }

  bindClick = data => {
    const { id, isOld, companyId } = data
    if (!isOld) {
      navigateTo({
        url: `${pagejumplist['job-detail'].path}?id=${id}&companyId=${companyId}`
      })
    } else {
      // 老数据
      navigateTo({
        url: `${pagejumplist['job-detail'].path}?id=${id}&isOld=${isOld}&companyId=${companyId}`
      })
    }
  }

  render () {
    const { landmarkName, barlevecurrent } = this.props
    return (
      <View className="JobsList_id26630" style={this.props.styleWrap ? this.props.styleWrap : {}}>
        {this.props.dataSource.map((data, index) => {
          return (
            <JobListItem 
              data={data}
              landmarkName={landmarkName}
              barlevecurrent={barlevecurrent}
              bindClick={this.bindClick}
            />
          )
        })}
      </View>
    )
  }
}

JobsList.defaultProps = {
  dataSource: [],
  landmarkName: ''
}
export default JobsList
